package Course12;

import java.util.ArrayList;
import java.util.Iterator;

public class Array {
    public static void main(String[] args) {
        ArrayList arrayList=new ArrayList();
        arrayList.add("张三");
        arrayList.add("李四");
        arrayList.add("王五");
        //System.out.println("ArrayList的元素个数为:"+arrayList.size());
        System.out.println(arrayList);
        //遍历方法1
        Iterator iterator=arrayList.iterator();
        while(iterator.hasNext()){
            String name=(String)iterator.next();
            System.out.println(name);
        }
        //遍历方法2
        for(int i=0;i<arrayList.size();i++){
            System.out.println(arrayList.get(i));
        }
    }
}
